home *** CD-ROM | disk | FTP | other *** search
-
-
- Public Class DialogInheritedForm
- Inherits WindowsFormsDemo.DialogBaseForm
-
- #Region " Windows Form Designer generated code "
-
- Public Sub New()
- MyBase.New()
-
- 'This call is required by the Windows Form Designer.
- InitializeComponent()
-
- 'Add any initialization after the InitializeComponent() call
-
- End Sub
-
- 'Form overrides dispose to clean up the component list.
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
- Friend WithEvents chkUpperCase As System.Windows.Forms.CheckBox
-
- 'Required by the Windows Form Designer
- Private components As System.ComponentModel.Container
-
- 'NOTE: The following procedure is required by the Windows Form Designer
- 'It can be modified using the Windows Form Designer.
- 'Do not modify it using the code editor.
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.chkUpperCase = New System.Windows.Forms.CheckBox()
- Me.SuspendLayout()
- '
- 'txtValue
- '
- Me.txtValue.Visible = True
- '
- 'btnCancel
- '
- Me.btnCancel.Visible = True
- '
- 'btnOK
- '
- Me.btnOK.Enabled = False
- Me.btnOK.Visible = True
- '
- 'lblMessage
- '
- Me.lblMessage.Text = "Type a string without any spaces in it"
- Me.lblMessage.Visible = True
- '
- 'chkUpperCase
- '
- Me.chkUpperCase.Location = New System.Drawing.Point(56, 96)
- Me.chkUpperCase.Name = "chkUpperCase"
- Me.chkUpperCase.Size = New System.Drawing.Size(208, 32)
- Me.chkUpperCase.TabIndex = 4
- Me.chkUpperCase.Text = "Convert to UpperCase"
- '
- 'DialogInheritedForm
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(7, 17)
- Me.ClientSize = New System.Drawing.Size(512, 149)
- Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtValue, Me.btnCancel, Me.btnOK, Me.lblMessage, Me.chkUpperCase})
- Me.Name = "DialogInheritedForm"
- Me.Text = "DialogInheritedForm"
- Me.ResumeLayout(False)
-
- End Sub
-
- #End Region
-
- ' in this inherited form we enable the OK button only after the user enters a string
- Private Sub txtValue_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtValue.TextChanged
- Me.btnOK.Enabled = (txtValue.Text <> "")
- End Sub
-
- ' Convert to uppercase if so requested
- Private Sub txtValue_KeyPress(ByVal sender As System.Object, ByVal e As KeyPressEventArgs) Handles txtValue.KeyPress
- If Char.IsLower(e.KeyChar) AndAlso chkUpperCase.Checked Then
- txtValue.SelectedText = Char.ToUpper(e.KeyChar)
- e.Handled = True
- End If
- End Sub
-
- ' in this inherited form we reject strings that contain space
- Protected Overrides Sub OnOkClick()
- ' call the base form procedure only if the string doesn't contain space
- If InStr(txtValue.Text, " ") = 0 Then
- MyBase.OnOkClick()
- Else
- MessageBox.Show("Please remove all spaces from this string", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End If
- End Sub
-
- End Class
-